package com.xd.study.activity;

import android.app.Activity;
import android.app.Fragment;
import android.app.FragmentManager;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import com.xd.study.R;
import com.xd.study.fragment.StaticFragment;

/**
 * Created by DGF on 2015/4/24.
 */
public class FragmentStaticActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.fragment_static);

        Button button = (Button)this.findViewById(R.id.fragment_ok);
        button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                TextView textView = (TextView)FragmentStaticActivity.this.findViewById(R.id.fragment_textview);
                textView.setText("textview的值改变了");

                //向Fragment传递参数
                FragmentManager fragmentManager = getFragmentManager();
                Fragment fragment = fragmentManager.findFragmentById(R.id.fragment_static);
                StaticFragment staticFragment = (StaticFragment)fragment;
                staticFragment.setContent("hello, my static fragment");
            }
        });
    }
}
